//app.js
const Promise = require('promise/promise.js');
App({
  onLaunch: function() {
    // 展示本地存储能力
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

  },
  getOpenId: function(res) {
    var that = this
    return new Promise(function(resolve, reject) {
      wx.login({
        success: res => {
         
          wx.request({
            url: 'http://xxxxxxx:8080/webchat/login/queryOpenid',
            data: {
              code: res.code
            },
            success: res => {
              console.log(res.data)
              that.globalData.openId = res.data.data.openId;
              resolve(res)
            }
          })
        }
      })
    })
  },
  globalData: {
    userInfo: null,
    openId: 0,
  }

})